#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int MAXN = 2010;
const int MOD = 998244353;

int n, a;
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    set<int> s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        s.insert(a);
    }

    int mex = 0;
    while(1) {
        if (s.find(mex) == s.end()) {
            break;
        }
        mex++;
    }
    cout << mex << endl;
    return 0;
}